package wx.event.entity.weixing;

import lombok.Data;

import java.util.Map;

/**
 * 接收到微信服务器事件请求
 */
@Data
public class WxEventRequest {
    private String fromUserName;    //发送方账号(open_id)
    private String toUserName;      //公众账号id
    private String msgType;         //消息类型
    private String content;         //消息内容
    private String signature;       //微信加密签名
    private String timestamp;       //时间戳
    private String nonce;           //随机数
    private String echostr;         //随机字符串
    private String recognition;     //语音消息识别结果
    private String eventType;       //事件类型
    private String eventKey;        //扫描带参数二维码信息（未关注（参数中包括_），和已关注扫描(参数中无_)）

    public WxEventRequest(Map<String, String> requestMap){
        this.fromUserName = requestMap.get("FromUserName");
        this.toUserName = requestMap.get("ToUserName");
        this.msgType = requestMap.get("MsgType");
        this.content = requestMap.get("Content");
        this.signature = requestMap.get("signature");
        this.timestamp = requestMap.get("timestamp");
        this.nonce = requestMap.get("nonce");
        this.echostr = requestMap.get("echostr");
        this.recognition = requestMap.containsKey("Recognition")?requestMap.get("Recognition"):null;
        this.eventType = requestMap.containsKey("Event")?requestMap.get("Event"):null;
    }
}
